import Foundation
@testable import SwiftUI_Demo

class MockComponentsUseCase: ComponentsUseCase {
    var shouldSucceed = true
    var mockComponents: [HomeComponent] = [
        .banner(title: "测试横幅"),
        .quickEntry(items: [
            QuickEntryItem(title: "测试入口1", iconName: "icon1"),
            QuickEntryItem(title: "测试入口2", iconName: "icon2")
        ]),
        .promotion(title: "测试促销")
    ]
    
    var fetchComponents: (() async throws -> [HomeComponent])?
    
    func fetchComponents() async throws -> [HomeComponent] {
        if let customFetch = fetchComponents {
            return try await customFetch()
        }
        
        if shouldSucceed {
            return mockComponents
        } else {
            struct MockError: Error {}
            throw MockError()
        }
    }
}